package io.renren.modules.sale.service.impl;

import io.renren.modules.sale.entiy.XYContent;
import io.renren.modules.sale.entiy.XYQuestion;
import io.renren.modules.sale.entiy.XYUser;
import io.renren.modules.sale.service.IXYQA;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class XYQAImpl implements IXYQA {

    private static final String QA_STATEMENT = "qa.";

    @Autowired
    SqlSessionTemplate sqlSessionTemplate;

    @Override
    public boolean isUserExists(XYUser xyUser) {
        List<XYUser> userList = sqlSessionTemplate.selectList(QA_STATEMENT + "isUserExists", xyUser);
        return userList.size() != 0;
    }

    @Override
    public boolean isQuestionAnswered(XYContent xyContent) {
        List<XYContent> contentList = sqlSessionTemplate.selectList(QA_STATEMENT + "isQuestionAnswered", xyContent);
        return contentList.size() != 0;
    }

    @Override
    public boolean isQuestionExists(XYQuestion xyQuestion) {
        return false;
    }

    @Override
    public int insertQuestion(XYQuestion xyQuestion) {
        return 0;
    }

    @Override
    public int insertContent(XYContent xyContent) {
        return sqlSessionTemplate.insert(QA_STATEMENT + "insertContent", xyContent);
    }

    @Override
    public int updateContent(XYContent xyContent) {
        return 0;
    }

    @Override
    public int insertUser(XYUser xyUser) {
        return 1;
    }
}
